
const CryptoJS = require('crypto-js');
const key  = CryptoJS.enc.Utf8.parse("4c43c365a4ac05b91eb5fa95"); // key
const iv = CryptoJS.enc.Utf8.parse("4c43c365"); // iv

function encrypted(params){
    const encrypted = CryptoJS.TripleDES.encrypt(params, key, {
        iv: iv,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
    });

    return encrypted.toString(); // 返回加密后的字符串
}
function decrypted(params) {
    const decrypted = CryptoJS.TripleDES.decrypt(params, key, {
        iv: iv,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
    }).toString(CryptoJS.enc.Utf8);

    return decrypted // 返回解密后的字符串
}
function decrypted2() {
    console.log(CryptoJS.mode.CBC)
    console.log(CryptoJS.pad.Pkcs7)
    const params = '9L241rcB6wyu5OLp22Cu0nYRvrOebvA/PR4BUzrKb6EJt8t5VZFy9A==';
    const key  = CryptoJS.enc.Utf8.parse("12345678123456781234567812345678"); // key
    const decrypted = CryptoJS.TripleDES.decrypt(params, key, {
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
    }).toString(CryptoJS.enc.Utf8);
    return decrypted // 返回解密后的字符串
}

const encryptResult = encrypted('<h2>Hello Word</h2>');
console.log('encryptResult: ', encryptResult);

const decryptResult = decrypted(encryptResult);
console.log('decryptResult: ', decryptResult);

const decryptResult2 = decrypted2();
console.log('decryptResult: ', decryptResult2);

